package parser;

import java.util.Stack;

public class SyntaxNodePrinter
{
    static String TREE_SEGMENT = "..";
    private Stack<String> treeHierarchyStack = new Stack<String>();

    public void PrintSyntaxNode(SyntaxNode node)
    {
        PrintTreeHierarchy();
        System.out.println(node);
        treeHierarchyStack.push(TREE_SEGMENT);
        if (node.HasChildren())
        {
            for (int i = 0; i < node.GetChildrenCount(); i++)
            {
                PrintSyntaxNode(node.GetChild(i));
            }
        }
        treeHierarchyStack.pop();
    }

    private void PrintTreeHierarchy()
    {
        for (String str : treeHierarchyStack)
        {
            System.out.print(str);
        }
    }
}
